<?php
	//接收用户的数据
	$id = $_POST['id'];
	$password = $_POST['password'];
	
	//第一个版本：不连接数据库
// 	if($id=="admin"&&"admin"==$password){
// 		header("location:main.php");
// 	}else{
// 		header("location:login.php?errorNo=1");
// 	}
	//第二种版本：到数据库验证 mysql扩张库，mysqli扩张库
	$conn = mysql_connect("localhost","root","root");
	if(!$conn){
		die("连接失败".mysql_errno());
	}
	mysql_query("set names utf8",$conn) or die(mysql_errno());
	mysql_select_db("emp",$conn) or die(mysql_errno());
	
	$sql = "select password,name from admin where id = $id";
	
	$res = mysql_query($sql);
		
	if($row= mysql_fetch_assoc($res)){
		echo $row['password'];
		echo md5($password);
		$name = $row['name'];
		if($row['password']==md5($password)){
			header("location:main.php?name=$name");
			exit();
		}
	}
	mysql_free_result($res);
	mysql_close();
	header("location:login.php?errorNo=1");
	exit();